package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.ESManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by 柱子 on 2020/10/21 22:10
 */
@RestController
@RequestMapping("/manager")
public class ESManagerController {

    @Autowired
    private ESManagerService esManagerService;

    /**
     * 创建索引库结构
     *
     * @return
     */
    @GetMapping("/create")
    public Result create() {
        esManagerService.createIndexAndMapping();
        return new Result(true, StatusCode.OK, StatusCode.CREATE_DATE_OK);
    }

    /**
     * 导入全部数据
     *
     * @return
     */
    @GetMapping("/importAll")
    public Result importAll() {
        esManagerService.importAll();
        return new Result(true, StatusCode.OK, StatusCode.ADD_DATE_OK);
    }

}
